package com.sztx.pay.center.tool;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSONObject;

public class CompareFile {
	private static Logger logger = LoggerFactory.getLogger(CompareFile.class);
	private static HashSet<String> tmpsourceSet = new HashSet<String>();
	private static HashSet<String> tmptargetSet = new HashSet<String>();
	public static void main(String[] args)throws IOException {
		BufferedReader bfs = new BufferedReader(new FileReader("E:/文档/20161108/支付中心所有帐号.txt"));
		BufferedReader bft = new BufferedReader(new FileReader("E:/文档/20161108/用户中心所有帐号.txt"));
		HashSet<String> sourceSet = new HashSet<String>();
		HashSet<String> targetSet = new HashSet<String>();
		
		String readLine = null;
		
		while ((readLine = bfs.readLine()) != null){
			sourceSet.add(readLine.trim());
		}
		while ((readLine = bft.readLine()) != null){
			targetSet.add(readLine.trim());
		}
		
		compareSet(sourceSet, targetSet);
		
		logger.info("支付存在,缴费不存在帐号  数量:"+tmpsourceSet.size()+"  json:"+JSONObject.toJSONString(tmpsourceSet));
		logger.info("缴费存在,支付不存在帐号  数量:"+tmptargetSet.size()+" json:"+JSONObject.toJSONString(tmptargetSet));
		
	}
	
	private static void compareSet(HashSet<String> sourceSet,HashSet<String> targetSet){
		for (String tmpStr : sourceSet) {
			if(!targetSet.contains(tmpStr)){
				tmpsourceSet.add(tmpStr);
			}
		}
		for (String tmpStr : targetSet) {
			if(!sourceSet.contains(tmpStr)){
				tmptargetSet.add(tmpStr);
			}
		}
	}
}
